package pacificlms.Verifiable;

import java.lang.reflect.*;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.AccessibleObject.*;

/**
 * ReflectionHelper contains static methods to help with reflection
 * @author Brian Hume
 */
public class ReflectionHelper
{
    /**
     * CreateEmptyInstance creates an instance of the specified class via the parameterless constructor
     * @param NewClass The class type to be created
     * @return An instance of the class, or null if there was an error
     */ 
    public final static Object CreateEmptyInstance(Class NewClass)
    {
        try
        {
            Object NewInstance = null;
            
            Constructor[] ConList = NewClass.getConstructors();
            
            for (Constructor Con : ConList)
            {
                if (Con.getParameterTypes().length == 0)
                {
                    NewInstance = (Object)Con.newInstance();
                    break;
                }
            }
            
            return NewInstance;
        }
        catch(Exception Ex)
        {
            return null;
        }
    }
}
